Skip to content

London | 26-SDC-July | Alex Jamshidi | Sprint 4 | Implement shell tools in python - #676

Open
Alex-Jamshidi wants to merge 30 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:implement-shell-tools-in-python
Open

Alex-Jamshidi wants to merge 30 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:implement-shell-tools-in-python

Conversation

@Alex-Jamshidi

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1152

Changelist

Implemented wc, ls, cat in python

@Alex-Jamshidi Alex-Jamshidi added 📅 Sprint 4 Assigned during Sprint 4 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Aug 30, 2026
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Sep 1, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start on this task. Reading through it, I can see you have put thought into these implementations, but they feel a little bit over-engineered, and at times are a bit difficult to see how the data is flowing through them. I've got a few questions for you to answer which might help me better understand your thinking.

Comment thread implement-shell-tools/cat/cat.py
Comment thread implement-shell-tools/cat/cat.py
Comment thread implement-shell-tools/ls/ls.py
Comment thread implement-shell-tools/ls/ls.py Outdated
if not (Path(cwd) / p).is_dir()
]
if not flag_status["show_all"]:
file_args = remove_dot_files(file_args)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple places where you use remove_dot_files in this program. Is there a reason for that?

@Alex-Jamshidi Alex-Jamshidi Sep 12, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The program takes the original filesystem items (which could be files or folders, or both).

It then splits these items into files (get_file_args) and directories (get_dir_args).

The list of file arguments may contain dot files, like .hidden.txt, so these are removed at this stage.

If directory items are found, these need to be opened up, the contents of which are to be displayed on a separate line, this is done using the dir_output function. These directories may also contain dot files, so these need to be removed.

If the second instance of remove_dot_files were removed:
In the case of the sample files given, none of the sub directories actually contain dot files, so the output of ls and ls.py would be equivalent.

but if I ran, for example: python3 ls.py ./* whereby sample-files is now a subdirectory to be opened.

then when the dir_output function populates the files in sample-files, the .hidden.txt would be incorrectly shown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand. The dotfiles are treated a little differently in the case of directories that need to be inspected. That makes sense in this case.

Comment thread implement-shell-tools/wc/wc.py Outdated
Comment thread implement-shell-tools/wc/wc.py Outdated
Comment thread implement-shell-tools/wc/wc.py Outdated
@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Sep 1, 2026
@Alex-Jamshidi Alex-Jamshidi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 12, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks more complete now, good work

if not (Path(cwd) / p).is_dir()
]
if not flag_status["show_all"]:
file_args = remove_dot_files(file_args)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand. The dotfiles are treated a little differently in the case of directories that need to be inspected. That makes sense in this case.

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Tools The name of the module. 📅 Sprint 4 Assigned during Sprint 4 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants